package com.bjsxt.collection;

import java.util.ArrayList;
import java.util.List;

public class ArratListTest {
//    面向对象编程就是面向接口编程
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        boolean  flag = list.add("dstf");
        boolean  flag2 = list.add("ds");
        System.out.println(flag);

        list.add(1,"jds");
        System.out.println(list);
        String s =list.get(2);
        System.out.println(s);
        System.out.println(list.size());
        System.out.println(list.remove("ds"));
        System.out.println(list.remove(1));
        list.add("jdys");
        list.add("jys");
        list.add("jdy");
        System.out.println(list);

        System.out.println(list.set(2,"sdg"));
        System.out.println(list.isEmpty());
        list.clear();
        System.out.println(list);
        System.out.println(list.isEmpty());
        list.add("jdys");
        list.add("jys");
        list.add("jdy");
        list.add("jdys");
        list.add("jdys");

        System.out.println(list.contains("jysq"));
        System.out.println(list.indexOf("jdys"));
        System.out.println(list.lastIndexOf("jdys"));

        //ArrayList -->object[]
        Object[] arr=list.toArray();
        System.out.println(arr);

        String[] arr2 = list.toArray(new String[list.size()]);

        List<String>  a = new ArrayList<>();
        a.add("a");
        a.add("b");
        a.add("c");
        List<String>  b = new ArrayList<>();
        b.add("b");
        b.add("c");
        b.add("d");

        boolean flag6 = a.addAll(b);
        System.out.println(flag6);
        System.out.println(a);

        boolean flag7 = a.retainAll(b);
        System.out.println(a);

        System.out.println(b);
        boolean flag8 = a.removeAll(b);
        System.out.println(a);


    }
}
